
If (isNil "D_CURRENT_BUILDING_LIST") then {D_CURRENT_BUILDING_LIST = _initial_list};


_building_creation_pos = getMarkerPos "building_creation_pos";
_initial_pos_player = getPos building_tester;

_building_marker_pos = getMarkerPos "building_creation_pos";
if (Format["%1",_building_marker_pos] == "[0,0,0]") then {["building_creator", _building_creation_pos, "ICON", "ColorRed", [0.9,0.9],"House",90,"hd_objective","",0.9] call XfCreateMarkerGlobal;};

// _found_buildings = +_done_list;
// {
	// _center = _x select 0;
	// if (count _center > 0) then {
		// _radius = 800;
		// _bldgs = nearestobjects [_center, ["building"], _radius];
		// {
			// _type = typeof _x;
			// if (!(_type in _found_buildings)) then {
				// _found_buildings set [count _found_buildings, _type];
				// diag_log format["%1",_type];
			// };
		// } foreach _bldgs;
	// };
// } foreach d_map_locations;
// hint "Done";

// if (count d_current_building_list > 0) then {
	// _new_building = d_current_building_list select 0;
	// d_current_building_list set [0, "xdelx"];
	// d_current_building_list = d_current_building_list - ["xdelx"];
	
	// player setpos _initial_pos_player;
	// player setdir 180;
	// sleep 1.5;
	
	// if (isnil "d_current_building") then {d_current_building = objnull};
	
	// if (!isnull d_current_building) then {
		// deletevehicle d_current_building;
	// };
	// sleep 1;
	// d_current_building = createvehicle [_new_building,_building_creation_pos, [], 0, "none"] ;
	// d_current_building setDir 0;
	// sleep 1;
// } else {
	// player sidechat "no buildings left!";
// };

// those functions transforms the arrays extracted from the logfile to something useable.

_houses_indexer = [];
_houses_positions = [];
_house_subarray = [];
{
	diag_log Format["Item: %1",_x];
	_house_type = _x select 0;
	_position_type = _x select 1;
	_position_rel = _x select 2;
	_position_dir = _x select 3;
	_pos = _houses_indexer find _house_type;
	 diag_log Format["Pos: %1",_pos];
	if (_pos == -1) then {
		_pos = count _houses_indexer;
		_houses_indexer set [count _houses_indexer, _house_type];
	};
	if (_pos > count _houses_positions) then {
		_houses_positions set [_pos, [[],[],[]]];
		_house_subarray = _houses_positions select _pos;
	} else {
		_house_subarray = _houses_positions select _pos;
		if (isNil "_house_subarray") then {
			_houses_positions set [_pos, [[],[],[]]];
			_house_subarray = _houses_positions select _pos;
		};
	};
	 diag_log Format["Sub array: %1",_house_subarray];
	_position_list = _house_subarray select (_position_type);
	diag_log Format["Pos list: %1",_position_list];
	_position_list set [count _position_list, [_position_rel,_position_dir]];
	_house_subarray set [(_position_type), _position_list];
	_houses_positions set [_pos, _house_subarray];
}foreach _house_positions;

diag_log "#BUILDING_POSITION_INDEXER = [#";
{
	diag_log Format["#	,%1#",str(_x)];
} foreach _houses_indexer;
diag_log "#];#";


diag_log "#BUILDING_POSITION_INFOS = [#";
for [{_i = 0},{_i < count _houses_indexer},{_i = _i + 1}] do
{
	diag_log Format["#	//Building: %1#",(_houses_indexer select _i)];
	diag_log Format["#	[#"];
	_positions = _houses_positions select _i;
	diag_log Format["#		// Inside combat positions (windows, doors)#"];
	diag_log Format["#		[#"];
	_first = true;
	{
		if (_first) then {
			diag_log Format["#			%1#",_x];
			_first = false;
		} else {
			diag_log Format["#			,%1#", _x];
		};
	} foreach (_positions select 0);
	diag_log Format["#		],#"];

	diag_log Format["#		// Inside hiding positions (for AIs to hide like assassination targets#"];
	diag_log Format["#		[#"];
	_first = true;
	{
		if (_first) then {
			diag_log Format["#			%1#",_x];
			_first = false;
		} else {
			diag_log Format["#			,%1#", _x];
		};
	} foreach (_positions select 1);
	diag_log Format["#		],#"];

	diag_log Format["#		// Roof positions for snipers#"];
	diag_log Format["#		[#"];
	_first = true;
	{
		if (_first) then {
			diag_log Format["#			%1#",_x];
			_first = false;
		} else {
			diag_log Format["#			,%1#", _x];
		};
	} foreach (_positions select 2);
	diag_log Format["#		]#"];

	diag_log Format["#	],#"];
};
diag_log "#];#";

